package com.rush.yuaiagent.controller;

import com.rush.yuaiagent.agent.model.RushManus;
import com.rush.yuaiagent.app.LoveApp;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
public class AIcontroller {
    @Resource
    private ToolCallback[] toolCallback;
    @Resource
    private ChatModel chatModel;
    @Resource
    private LoveApp loveApp;
    /**
     * 流式调用
     */
    @GetMapping(value = "manus/chat", produces = "text/event-stream;charset=UTF-8")
    public SseEmitter doChatWithManus(String message) {
        RushManus rushManus = new RushManus(toolCallback, chatModel);
        return rushManus.runStream( message);
    }
    @GetMapping(value = "/love_app/chat/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> doChatWithLoveAppSse(String message, String chatId) {
        return loveApp.doChatByStream(message, chatId);
    }
}
